<?php

namespace app\admin\model;

use think\Model;

class User extends Model{
    protected $pk ='u_id';  
    
    public function profile(){
        return $this->hasOne(UserProfile::class,'u_id','u_id');
    }

    public function admin(){
        return $this->hasOne(Admin::class,'u_id','u_id');
    }


    public function getSexTextAttr($value,$data){
        $sexs = [1=>'男',2=>'女'];
        return $sexs[$data['sex']];
    }


    public function getStatusTextAttr($value,$data){
        $status = [1=>'正常',0=>'禁用'];
        return $status[$data['status']];
    }

    public function roles(){
        return $this->hasMany(RoleUser::class,'u_id','u_id');
    }


    

    


 }